home *** CD-ROM | disk | FTP | other *** search
/ Mission 3 / Mission 3.zip / Mission 3.iso / texte / 7up_pd / printer5.c < prev    next >
C/C++ Source or Header  |  1998-10-29  |  55KB  |  2,094 lines

  1. /* Druckausgabe (auch VDI/Metafile) */
  2. /*****************************************************************************
  3. *
  4. *                                              7UP
  5. *                                      Modul: PRINTER.C
  6. *                                     (c) by TheoSoft '90
  7. *
  8. *****************************************************************************/
  9. #include <portab.h>
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <string.h>
  13. #include <aes.h>
  14. #include <vdi.h>
  15. #if GEMDOS
  16. #include <tos.h>
  17. #else
  18. #include <bios.h>
  19. #include <alloc.h>
  20. #endif
  21.  
  22. #include "alert.h"
  23.  
  24. #include "windows.h"
  25. #include "forms.h"
  26. #include "7UP.h"
  27.  
  28. void _V_opnwk(int work_in[], int *handle, int work_out[]);
  29. int open_work (int device);
  30. void close_work (int handle, int device);
  31. char *expandfkey(WINDOW *wp, char *str, int page);
  32. char *split_fname(char *name);
  33. int getfilename(char *pathname, char * pattern, char *fname, const char *meldung);
  34. char *change_ext(char *name, char *ext);
  35. char *change_name(char *name, char *newname);
  36.  
  37. #define TEXT      0  /* windowtype */
  38. #define GRAPHIC  1
  39. #define PRT        0
  40. #define DESK      0
  41. #define TRUE      1
  42. #define FALSE     0
  43. #define VERTICAL 1
  44.  
  45. #define SPOOLER_ACK 101
  46. #define WM_BACKDROPPED    31        /* Message vom Eventhandler */
  47.  
  48. #define SCREEN            1
  49. #define PLOTTER         11
  50. #define PRINTER         21
  51. #define METAFILE        31
  52. #define CAMERA          41
  53. #define TABLET          51
  54.  
  55. #define FONT_SYSTEM    1                         /* GEM System Font */
  56. #define FONT_SWISS     2                         /* Swiss Font */
  57. #define FONT_DUTCH    14                         /* Dutch Font */
  58.  
  59. #define BELL 7
  60. #define FORMFEED 0x0C
  61. #define LINEFEED '\n'
  62. #define BLANK     ' '
  63. #define RESET     "\\@"
  64. #define ESC        0x01
  65. #define X_MIN 8
  66. #define Y_MIN 0 /*(3*ch)*/
  67. #define UNPRINTABLE_LINES 0  /* 2 mit Fontfix und DJ5. Ohne Fontfix > 3 */
  68.  
  69. extern int gl_apid;
  70. extern char alertstr[];
  71. extern char iostring[],iostr2[];
  72. extern OBJECT *gdospop,*paperpop,*distpop,*layout;
  73. extern int work_in[103],work_out[57];
  74. extern int boxh,windials;
  75.  
  76. int zl=80,bl=72,or=4,kz=0,fz=0,ur=4,lr=0,zz=64,
  77.      pageoffset=0,fpage=1,lpage=9999,copies=1,fcol=1,lcol=512;     /* auch für Preview */
  78.  
  79. int act_dev=POPNO, act_paper=POPBASIS/*POPLETT*/, act_dist=POPD1;
  80.  
  81. #define MAXDEVICES 32
  82.  
  83. typedef struct
  84. {
  85.    int flags;
  86.    int state;
  87.    int retcode;
  88.     char devname[25];
  89.     int devno;
  90. }TGDOSINFO;
  91.  
  92. typedef struct
  93. {
  94.    long count;
  95.    TGDOSINFO gdosinfo[MAXDEVICES];
  96. }TSCROLLIST;
  97.  
  98. TSCROLLIST *scrollist=NULL;
  99.  
  100. typedef struct
  101. {
  102.     int w,h;
  103. }PAPERSIZE;
  104.  
  105. static PAPERSIZE ps[]=
  106. {
  107. /* OUTPUT     */
  108.         0,   0,  /* Default-Einstellung des Treibers */
  109.     2100,3048,  /* Letter */
  110.     2159,3556,  /* Legal  */
  111.     2159,1397,  /* Half    */
  112.     3380,3048,  /* Ledger */
  113.     2970,4200,  /* DIN A3 */
  114.     2100,2970,  /* DIN A4 */
  115.     1485,2100,  /* DIN A5 */
  116.     1820,2500,  /* DIN B5 */
  117.     3553,2794    /* Wide    */
  118. };
  119.  
  120. static int msgbuf[8];
  121. static MEVENT mevent=
  122. {
  123.     MU_TIMER|MU_KEYBD|MU_BUTTON|MU_MESAG,
  124.     2,1,1,
  125.     0,0,0,0,0,
  126.     0,0,0,0,0,
  127.     msgbuf,
  128.     25L,
  129.     0,0,0,0,0,0,
  130. /* nur der Vollständigkeit halber die Variablen von XGEM */
  131.     0,0,0,0,0,
  132.     0,
  133.     0L,
  134.     0L,0L
  135. };
  136.  
  137. int is_busy(void)
  138. {
  139. #if GEMDOS
  140.     return(Cprnos());
  141. #else
  142.     return((biosprint(2,0,0) == 0x90) | (biosprint(2,0,1) == 0x90));
  143.                             /* LPT1        oder         LPT2 */
  144. #endif
  145. }
  146.  
  147. int FPRINTF(FILE* fp, const char *fmt, ...)
  148. {
  149.     va_list argptr;
  150.     register int i,cnt;
  151.  
  152.     va_start(argptr,fmt);
  153.     cnt=vsprintf(iostr2,fmt,argptr);
  154.     if(scrollist->gdosinfo[POPNO-1].state & SELECTED/*gdospop[POPNO].ob_state & CHECKED*/) /* keine Zeichenkonvertierung */
  155.         fprintf(fp,"%s",iostr2);
  156.     if(scrollist->gdosinfo[POPIBM-1].state & SELECTED/*gdospop[POPIBM].ob_state & CHECKED*/) /* IBM Druckeranpassung */
  157.     {
  158.         for(i=0; i<cnt; i++)
  159.         {
  160.             switch((unsigned char)iostr2[i])
  161.             {
  162.                 case 0x9E: /* β */
  163.                     fprintf(fp,"β");
  164.                     break;
  165.                 case 0xDD: /* § */
  166.                     fprintf(fp,"%c",0x15);
  167.                     break;
  168.                 default:
  169.                     fprintf(fp,"%c",iostr2[i]);
  170.                     break;
  171.             }
  172.         }
  173.     }
  174.     if(scrollist->gdosinfo[POPEPS-1].state & SELECTED/*gdospop[POPEPS].ob_state & CHECKED*/) /* EPSON Druckeranpassung */
  175.     {
  176.         for(i=0; i<cnt; i++)
  177.         {
  178.             switch((unsigned char)iostr2[i])
  179.             {
  180.                 case 0x81: /* ü */
  181.                     fprintf(fp,"%c%c%c%c%c%c%c",0x1B,0x52,0x02,0x7D,0x1B,0x52,0x00);
  182.                     break;
  183.                 case 0x84: /* ä */
  184.                     fprintf(fp,"%c%c%c%c%c%c%c",0x1B,0x52,0x02,0x7B,0x1B,0x52,0x00);
  185.                     break;
  186.                 case 0x8E: /* Ä */
  187.                     fprintf(fp,"%c%c%c%c%c%c%c",0x1B,0x52,0x02,0x5B,0x1B,0x52,0x00);
  188.                     break;
  189.                 case 0x94: /* ö */
  190.                     fprintf(fp,"%c%c%c%c%c%c%c",0x1B,0x52,0x02,0x7C,0x1B,0x52,0x00);
  191.                     break;
  192.                 case 0x99: /* Ö */
  193.                     fprintf(fp,"%c%c%c%c%c%c%c",0x1B,0x52,0x02,0x5C,0x1B,0x52,0x00);
  194.                     break;
  195.                 case 0x9A: /* Ü */
  196.                     fprintf(fp,"%c%c%c%c%c%c%c",0x1B,0x52,0x02,0x5D,0x1B,0x52,0x00);
  197.                     break;
  198.                 case 0x9E: /* β */
  199.                     fprintf(fp,"%c%c%c%c%c%c%c",0x1B,0x52,0x02,0x7E,0x1B,0x52,0x00);
  200.                     break;
  201.                 case 0xDD: /* § */
  202.                     fprintf(fp,"%c%c%c%c%c%c%c",0x1B,0x52,0x02,0x40,0x1B,0x52,0x00);
  203.                     break;
  204.                 case 0xE1: /* β */
  205.                     fprintf(fp,"%c%c%c%c%c%c%c",0x1B,0x52,0x02,0x7E,0x1B,0x52,0x00);
  206.                     break;
  207.                 default:
  208.                     fprintf(fp,"%c",iostr2[i]);
  209.                     break;
  210.             }
  211.         }
  212.     }
  213.     va_end(argptr);
  214.     return(cnt);
  215. }
  216.  
  217. print_block(WINDOW *wp, LINESTRUCT *beg, LINESTRUCT *end)
  218. {
  219.     int ret, kstate;
  220.     LINESTRUCT *line;
  221. /*
  222. #if GEMDOS
  223.     FILE *stdprn;
  224. #endif
  225. */
  226.     graf_mouse(BUSY_BEE,0L);
  227.  
  228.     if(!scrollist)
  229.         scan_assignsys(layout, gdospop);
  230.  
  231.     if(wp && beg && end)
  232.     {
  233.         line=beg;
  234.         if(is_busy())
  235.         {
  236.             graf_mkstate(&ret, &ret, &ret, &kstate); /* Shifttaste? */
  237. /*
  238. #if GEMDOS
  239.             stdprn=fopen("PRN:","w");
  240. #endif
  241. */
  242.             do
  243.             {
  244.                 strcpy(iostring,&line->string[line->begcol]);
  245.                 iostring[line->endcol-line->begcol]=0;
  246.                 FPRINTF(stdprn,"\r%s\r\n",iostring);
  247.                 line=line->next;
  248.             }
  249.             while(line!=end->next);
  250.             fflush(stdprn);
  251.             if(kstate & (K_LSHIFT|K_RSHIFT))        /* bei gedrückter Shifttaste... */
  252.                 FPRINTF(stdprn,"%c",FORMFEED);      /* ...FORMFEED senden */
  253. /*
  254. #if GEMDOS
  255.             fclose(stdprn);
  256. #endif
  257. */
  258.         }
  259.         else
  260.             form_alert(1,Aprinter[0]);
  261.     }
  262.     graf_mouse(ARROW,0L);
  263. }
  264.  
  265. spool(char *filename, int copies, int mode)
  266. {
  267.     unsigned int spoolmsg[8];
  268.     int accid;
  269.     accid=appl_find("CALCLOCK");/* genau 8 Buchstaben, sonst mit BLANKS auffüllen */
  270.     if(accid<0)
  271.         accid=appl_find("1STGUIDE");/* genau 8 Buchstaben, sonst mit BLANKS auffüllen */
  272.     if(accid>=0)
  273.     {
  274.         spoolmsg[0]=100;
  275.         spoolmsg[1]=gl_apid;
  276.         spoolmsg[2]=0;         /* lt. DRI -1, darf aber nicht so sein! */
  277.         spoolmsg[3]=strlen(filename);
  278. #if MSDOS
  279.         spoolmsg[5]=(unsigned int)((long)filename >> 16);
  280.         spoolmsg[4]=(unsigned int)((long)filename & 0xffff);
  281. #else
  282.         spoolmsg[4]=(unsigned int)((long)filename >> 16);
  283.         spoolmsg[5]=(unsigned int)((long)filename & 0xffff);
  284. #endif
  285.         spoolmsg[6]=copies;
  286.         spoolmsg[7]=mode;
  287. #if OLDTOS
  288.         wind_update(END_UPDATE);
  289. #endif
  290.         appl_write(accid,16,spoolmsg);
  291. #if OLDTOS
  292.         wind_update(BEG_UPDATE);
  293. #endif
  294.     }
  295.     else
  296.         form_alert(1,Aprinter[1]);
  297. }
  298.  
  299. static int draftprint(OBJECT *tree1, OBJECT *tree2, OBJECT *tree3, WINDOW *wp, FILE *fp)
  300. {
  301.     register LINESTRUCT *line;
  302.     int i,k,m,pages,ret,blanks,inrange,mouse_click;
  303.     long lines,chars,count=1;
  304.     char c1,c2,*str;
  305.     FILE *save;
  306.     int event,wh,result=TRUE;
  307.     extern int dial_handle;
  308. /*
  309.     graf_mouse(BUSY_BEE,NULL);
  310. */
  311.     save=fp;                                                      /* Filepointer retten */
  312.     form_write(tree1,PRTNAME,(char *)Wname(wp),FALSE);
  313.     form_write(tree1,PRTPAGE,"",FALSE);
  314.     tree1[ROOT+1].ob_flags|=HIDETREE;
  315.     form_exopen(tree1,FALSE);
  316.     Wtxtsize(wp,&lines,&chars);
  317.     pages=lines%zz ? (lines/zz)+1 : lines/zz;            /* Anzahl der Seiten */
  318.     line=wp->fstr;
  319.     for(i=0;i<pages;i++)                                            /* für jede Seite */
  320.     {
  321.         event=evnt_event(&mevent);
  322. /*
  323.         wind_update(BEG_UPDATE);
  324. */
  325.         if(event & MU_MESAG)
  326.         {
  327.             if((msgbuf[0] != MN_SELECTED) && (msgbuf[0] < 50)) /* AP_TERM */
  328.             {
  329.                 if(msgbuf[3]==dial_handle) /* Dialogfenster */
  330.                 {
  331.                     switch(msgbuf[0])
  332.                     {
  333.                         case WM_BACKDROPPED: /* nein, niemals */
  334.                             break;
  335.                         case WM_REDRAW:
  336.                             fwind_redraw(tree1,msgbuf[3],&msgbuf[4]);
  337.                             break;
  338.                         case WM_MOVED:
  339.                             fwind_move(tree1,msgbuf[3],&msgbuf[4]);
  340.                             break;
  341.                         case WM_TOPPED:
  342.                             wind_set(msgbuf[3],WF_TOP,0,0,0,0);
  343.                             break;
  344.                     }
  345.                 }
  346.                 else /* aber kein Schlieβen oder Toppen */
  347.                     if(msgbuf[0]!=WM_CLOSED && msgbuf[0]!=WM_TOPPED)
  348.                         Wwindmsg(Wp(msgbuf[3]),msgbuf);
  349.             }
  350.         }
  351.         if(event&MU_KEYBD || event&MU_BUTTON)
  352.         {
  353.             if((mevent.e_kr>>8)==ESC ||                             /* ESC gedrückt? */
  354.                  objc_find(tree1,ROOT,MAX_DEPTH,mevent.e_mx,mevent.e_my)==PRTESC)
  355.             {
  356.                 objc_change(tree1,PRTESC,0,tree1->ob_x,tree1->ob_y,
  357.                                                     tree1->ob_width,tree1->ob_height,
  358.                                                     tree1[PRTESC].ob_state|SELECTED,TRUE);
  359.                 if(form_alert(2,Aprinter[4])==2)
  360.                 {
  361. /*
  362.                     wind_update(END_UPDATE);
  363. */
  364.                     result=FALSE;
  365.                     goto ENDE;
  366.                 }
  367.                 objc_change(tree1,PRTESC,0,tree1->ob_x,tree1->ob_y,
  368.                                                     tree1->ob_width,tree1->ob_height,
  369.                                                     tree1[PRTESC].ob_state&~SELECTED,TRUE);
  370.             }
  371.         }
  372. /*
  373.         wind_update(END_UPDATE);
  374. */
  375.         if(i+1+pageoffset <fpage)                              /* von, bis drucken */
  376.         {
  377.             fp=NULL;
  378.             inrange=FALSE;
  379.         }
  380.         else
  381.         {
  382.             fp=save;
  383.             inrange=TRUE;
  384.         }
  385.         if(i+1+pageoffset >lpage)
  386.         {
  387.             goto ENDE;
  388.         }
  389.  
  390.         if(inrange && !(tree3[PRNALLP].ob_state&SELECTED)) /* wenn nicht alle Seiten */
  391.         {
  392.             if(tree3[PRNPAIR].ob_state&SELECTED)          /* nur gerade Seiten */
  393.             {
  394.                 if((i+1+pageoffset)%2)                      /* bei ungerade weiter */
  395.                     fp=NULL;
  396.                 else
  397.                     fp=save;
  398.             }
  399.             else                                                  /* nur ungerade Seiten */
  400.             {
  401.                 if(!((i+1+pageoffset)%2))                     /* bei gerade weiter */
  402.                     fp=NULL;
  403.                 else
  404.                     fp=save;
  405.             }
  406.         }
  407.  
  408.         if(fp)
  409.         {
  410.             sprintf(alertstr,"%d",i+1);                 /* Seitennummer anzeigen */
  411.             form_write(tree1,PRTPAGE,alertstr,TRUE);
  412.         }
  413.  
  414.         for(k=0;k<or;k++)
  415.             if(fp) FPRINTF(fp,"\r\n");                                /* oberer Rand */
  416.         if(kz)                                                                 /* Kopfzeile */
  417.         {
  418.             str=expandfkey(wp,form_read(tree2,PRNKZSTR,alertstr),i+1+pageoffset);
  419.             ret=strlen(str);
  420.             if(tree2[PRNKZL].ob_state&SELECTED)                            /* links */
  421.                 blanks=lr;
  422.             if(tree2[PRNKZM].ob_state&SELECTED)                            /* mitte */
  423.                 blanks=lr+(zl-ret)/2;
  424.             if(tree2[PRNKZR].ob_state&SELECTED)                          /* rechts */
  425.                 blanks=(lr+zl-ret);
  426.  
  427.             if(tree3[PRNALT].ob_state&SELECTED)
  428.             {
  429.                 if(!((i+1+pageoffset)%2))    /* bei geraden Seiten vertauschen */
  430.                 {
  431.                     if(tree2[PRNKZR].ob_state&SELECTED)                  /* rechts */
  432.                         blanks=lr;
  433.                     if(tree2[PRNKZL].ob_state&SELECTED)                    /* links */
  434.                         blanks=(lr+zl-ret);
  435.                 }
  436.             }
  437.  
  438.             for(k=0; k<blanks; k++)
  439.                 if(fp) FPRINTF(fp," ");                                        /* BLANK */
  440.  
  441.             if(i==0) /* erste seite */
  442.             {
  443.                 if(!(tree3[PRNKFBEG].ob_state&SELECTED))            /* Kopfzeile */
  444.                 {
  445.                     if(fp)
  446.                         FPRINTF(fp,"\r\n");                  /* !KZ in erster Zeile */
  447.                 }
  448.                 else
  449.                     if(fp)
  450.                         FPRINTF(fp,"%s\r\n",str);             /* Kopfzeile drucken */
  451.             }
  452.             else
  453.                 if(fp)
  454.                     FPRINTF(fp,"%s\r\n",str);                 /* Kopfzeile drucken */
  455.             for(k=0; k<(kz-1); k++)
  456.                 if(fp) FPRINTF(fp,"\r\n");                                 /* rest KZ */
  457.         }
  458.         for(k=0; k<zz && line; k++, line=line->next,count++)
  459.         {
  460.             if(*line->string!=FORMFEED)
  461.             {
  462.                 if(tree3[PRNCUT].ob_state&SELECTED)/* überlange Zeilen abschneiden */
  463.                 {
  464.                     if(zl<line->used)
  465.                     {
  466.                         c1=line->string[zl];
  467.                         line->string[zl]=0;
  468.                     }
  469.                 }
  470.                 for(m=0;m<lr;m++)
  471.                     if(fp) FPRINTF(fp," ");                  /* BLANK, linker Rand */
  472.  
  473.                 if(lcol<line->used)
  474.                 {
  475.                     c2=line->string[lcol];                             /* Druckspalte */
  476.                     line->string[lcol]=0;
  477.                 }
  478.  
  479.                 if(tree3[PRNNUM].ob_state & SELECTED)    /* Zeilennummerierung */
  480.                     if(fp) FPRINTF(fp,"%5ld: ",count);
  481.  
  482.                 if((fcol-1)<line->used)
  483.                 {
  484.                     if(fp) FPRINTF(fp,"%s\r\n",&line->string[fcol-1]); /* Zeilen drucken */
  485.                 }
  486.                 else
  487.                 {
  488.                     if(fp) FPRINTF(fp,"\r\n");                      /* CRLF drucken */
  489.                 }
  490.                 if(lcol<line->used)
  491.                     line->string[lcol]=c2;
  492.  
  493.                 if(tree3[PRNCUT].ob_state&SELECTED)
  494.                 {
  495.                     if(zl<line->used)
  496.                     {
  497.                         line->string[zl]=c1;
  498.                     }
  499.                 }
  500.             }
  501.             else
  502.             {
  503.                 line=line->next;
  504.                 lines+=(zz-k);                              /* ...Zeilenzahl erhöhen */
  505.                 pages=lines%zz ? (lines/zz)+1 : lines/zz;/* Anzahl der Seiten */
  506.                 break;                      /* Seite beenden, aber FF nicht senden */
  507.             }
  508.         } /* for(k - zz) */
  509.         if(i<(pages-1))
  510.         {
  511.             for(; k<zz; k++)                                  /* evtl. Leerzeilen */
  512.                 if(fp) FPRINTF(fp,"\r\n");
  513.         }
  514.         else /* wenn letzte Seite... */
  515.         {
  516.             if(fz || tree3[PRNFF].ob_state&SELECTED)/* nur bei FZ oder Knopf */
  517.                 for(; k<zz; k++)                                 /* evtl. Leerzeilen */
  518.                     if(fp) FPRINTF(fp,"\r\n");
  519.         }
  520.         if(fz)                                                                  /* Fuβzeile */
  521.         {
  522.             str=expandfkey(wp,form_read(tree2,PRNFZSTR,alertstr),i+1+pageoffset);
  523.             ret=strlen(str);
  524.             for(k=0; k<(fz-1); k++)
  525.                 if(fp) FPRINTF(fp,"\r\n");                         /* Fuβleerzeilen */
  526.             if(tree2[PRNFZL].ob_state&SELECTED)                            /* links */
  527.                 blanks=lr;
  528.             if(tree2[PRNFZM].ob_state&SELECTED)                            /* mitte */
  529.                 blanks=lr+(zl-ret)/2;
  530.             if(tree2[PRNFZR].ob_state&SELECTED)                          /* rechts */
  531.                 blanks=(lr+zl-ret);
  532.  
  533.             if(tree3[PRNALT].ob_state&SELECTED)
  534.             {
  535.                 if(!((i+1+pageoffset)%2))              /* bei geraden Seiten vertauschen */
  536.                 {
  537.                     if(tree2[PRNFZR].ob_state&SELECTED)                  /* rechts */
  538.                         blanks=lr;
  539.                     if(tree2[PRNFZL].ob_state&SELECTED)                    /* links */
  540.                         blanks=(lr+zl-ret);
  541.                 }
  542.             }
  543.             for(k=0; k<blanks; k++)
  544.                 if(fp) FPRINTF(fp," ");                                            /* FZ */
  545.             if(i==0) /* erste Zeile */
  546.             {
  547.                 if(!(tree3[PRNKFBEG].ob_state&SELECTED))            /* Fuβzeile? */
  548.                 {
  549.                     if(fp)
  550.                         FPRINTF(fp,"\r\n");                                      /* nein */
  551.                 }
  552.                 else
  553.                     if(fp)
  554.                         FPRINTF(fp,"%s\r\n",str);              /* Fuβzeile drucken */
  555.             }
  556.             else
  557.                 if(fp)
  558.                     FPRINTF(fp,"%s\r\n",str);                  /* Fuβzeile drucken */
  559.         }/* fz */
  560.  
  561.         if(!(tree3[PRNFILE].ob_state&SELECTED))        /* wenn NICHT in Datei */
  562.         {
  563.             if(i<(pages-1))
  564.             {
  565.                 if(ur)                                             /* nur wenn unterer Rand */
  566.                     if(fp) FPRINTF(fp,"%c",FORMFEED);              /* Seitenvorschub */
  567.             }
  568.             else
  569.             {
  570.                 if(fz || tree3[PRNFF].ob_state&SELECTED)     /* FF am Textende? */
  571.                     if(fp) FPRINTF(fp,"%c",FORMFEED);          /* Seitenvorschub */
  572.             }
  573.         }
  574.         else  /* in Datei drucken */
  575.         {
  576.             if(i<(pages-1))
  577.             {                                                     /* nur wenn unterer Rand */
  578.                 for(k=0;k<ur;k++)
  579.                     if(fp) FPRINTF(fp,"\r\n");                     /* unterer Rand */
  580.             }
  581.         }
  582.         if(tree3[PRNPAUSE].ob_state&SELECTED)
  583.             if(form_alert(2,Aprinter[2])==1)
  584.             {
  585.                 result=FALSE;
  586.                 goto ENDE;
  587.             }
  588.     }
  589. ENDE:
  590.     fp=save;
  591.     fflush(fp);                                                             /* rausrotzen */
  592.     form_exclose(tree1,-1,FALSE);
  593.     tree1[PRTESC].ob_state&=~SELECTED;                                /* Bit löschen! */
  594. /*
  595.     graf_mouse(ARROW,NULL);
  596. */
  597.     return(result);
  598. }
  599.  
  600. static char *make_print_name(char *pname, char *name, char *ext)
  601. {
  602.     int k;
  603.     strcpy(pname,name);
  604.     k=strlen(pname);
  605.     if(pname[k-1]=='.')
  606.         pname[k-1]=0;
  607.     if(pname[k-2]=='.')
  608.         pname[k-2]=0;
  609.     if(pname[k-3]=='.')
  610.         pname[k-3]=0;
  611.     if(pname[k-4]=='.')
  612.         pname[k-4]=0;
  613.     strcat(pname,ext);
  614.     return(pname);
  615. }
  616.  
  617. void hndl_prtmenu(OBJECT *tree1, OBJECT *tree2, OBJECT *tree3, WINDOW *wp)
  618. {
  619.     FILE *fp;
  620.     static char filename[PATH_MAX];      /* wg. Spooler */
  621.     int exit_obj;
  622.     int a,b,c,d,e,f,g,h,i,j,k,l,m,kstate;
  623.     int x,y,mx,my,ret,done=FALSE;
  624.     static char fpattern[13]="";
  625.     LINESTRUCT *line,*beg,*end;
  626.  
  627. #if GEMDOS
  628.     int buff[2048];
  629. #endif
  630.  
  631.     if(!wp)
  632.       return;
  633.     if((act_dev>=POP21 && !vq_gdos()) ||
  634.         (act_dev>gdospop->ob_height/boxh)) /* ein Drucker weniger in Assign.sys */
  635.     {  /* Assign.sys fehlt wohl, und Seitenlayout wurde noch nicht beachtet */
  636.         form_alert(1,Aprinter[3]);
  637.         return;
  638.     }
  639.     if(act_dev>=POP21 || (appl_find("CALCLOCK")<0 && appl_find("1STGUIDE")<0))
  640.     {  /* nicht bei GDOS oder wenn die Spoolaccs fehlen */
  641.         tree3[PRNBACK].ob_state&=~SELECTED;
  642.         tree3[PRNBACK].ob_state|= DISABLED;
  643.         tree3[PRNDEL].ob_state&=~SELECTED;
  644.         tree3[PRNDEL].ob_state|= DISABLED;
  645.     }
  646.     else
  647.     {
  648.         tree3[PRNBACK].ob_state&=~DISABLED;
  649.         tree3[PRNDEL ].ob_state&=~DISABLED;
  650.     }
  651.     sprintf(tree3[PRNPGOFF].ob_spec.tedinfo->te_ptext,"%0004d",pageoffset);
  652.     sprintf(tree3[PRNFROM].ob_spec.tedinfo->te_ptext,"%0004d",fpage);
  653.     sprintf(tree3[PRNTO].ob_spec.tedinfo->te_ptext,"%0004d",lpage);
  654.     sprintf(tree3[PRNFCOL].ob_spec.tedinfo->te_ptext,"%003d",fcol);
  655.     sprintf(tree3[PRNLCOL].ob_spec.tedinfo->te_ptext,"%003d",lcol);
  656.     sprintf(tree3[PRNCOPY].ob_spec.tedinfo->te_ptext,"%02d",copies);
  657.     a=tree3[PRNNUM  ].ob_state; /* Objektstati für ABBRUCH merken */
  658.     b=tree3[PRNFILE ].ob_state;
  659.     c=tree3[PRNBACK ].ob_state;
  660.     d=tree3[PRNDEL  ].ob_state;
  661.     e=tree3[PRNKFBEG].ob_state;
  662.     f=tree3[PRNALT  ].ob_state;
  663.     g=tree3[PRNCUT  ].ob_state;
  664.     h=tree3[PRNALLP ].ob_state;
  665.     i=tree3[PRNPAIR ].ob_state;
  666.     j=tree3[PRNUNPA ].ob_state;
  667.     k=tree3[PRNPAUSE].ob_state;
  668.     l=tree3[PRNFF    ].ob_state;
  669.  
  670.     if(!scrollist)
  671.         scan_assignsys(layout, gdospop);
  672.       
  673.     form_exopen(tree3,0);
  674.     do
  675.     {
  676.         exit_obj=(form_exdo(tree3,0)&0x7fff);
  677.         switch(exit_obj)
  678.         {
  679.             case PRN2HELP:
  680.                 form_alert(1,Aprinter[6]);
  681.                 objc_change(tree3,exit_obj,0,tree3->ob_x,tree3->ob_y,
  682.                     tree3->ob_width,tree3->ob_height,tree3[exit_obj].ob_state&~SELECTED,TRUE);
  683.                 break;
  684.             case PRN2ABBR:
  685.             case PRN2OK:
  686.                 done=TRUE;
  687.                 break;
  688.         }
  689.     }
  690.     while(!done);
  691.     form_exclose(tree3,exit_obj,0);
  692.     if(exit_obj!=PRN2OK)
  693.     {
  694.         tree3[PRNNUM  ].ob_state=a; /* alles rückgängig machen */
  695.         tree3[PRNFILE ].ob_state=b;
  696.         tree3[PRNBACK ].ob_state=c;
  697.         tree3[PRNDEL  ].ob_state=d;
  698.         tree3[PRNKFBEG].ob_state=e;
  699.         tree3[PRNALT  ].ob_state=f;
  700.         tree3[PRNCUT  ].ob_state=g;
  701.         tree3[PRNALLP ].ob_state=h;
  702.         tree3[PRNPAIR ].ob_state=i;
  703.         tree3[PRNUNPA ].ob_state=j;
  704.         tree3[PRNPAUSE].ob_state=k;
  705.         tree3[PRNFF    ].ob_state=l;
  706.         return;
  707.     }
  708.     if(windials)
  709.     {
  710.         mevent.e_flags|=MU_MESAG;
  711.         graf_mouse(M_OFF,0L);
  712.         Wcursor(wp);         /* ausschalten */
  713.         evnt_event(&mevent); /* Dummyaufruf um Redraw zu killen */
  714.         Wredraw(wp,&msgbuf[4]);
  715.         Wcursor(wp);         /* einschalten */
  716.         graf_mouse(M_ON,0L);
  717.     }
  718.     else
  719.         mevent.e_flags&=~MU_MESAG;
  720.     pageoffset=atoi(form_read(tree3,PRNPGOFF,alertstr));
  721.     fpage=atoi(form_read(tree3,PRNFROM,alertstr));
  722.     lpage=atoi(form_read(tree3,PRNTO,alertstr));
  723.     if(fpage>lpage || fpage==0 || lpage==0)
  724.     {
  725.         form_alert(1,Aprinter[7]);
  726.         fpage=1;
  727.         lpage=9999;
  728.         return;
  729.     }
  730.     fcol=atoi(form_read(tree3,PRNFCOL,alertstr));
  731.     lcol=atoi(form_read(tree3,PRNLCOL,alertstr));
  732.     if(fcol>lcol || fcol==0 || lcol==0 || lcol>512)
  733.     {
  734.         form_alert(1,Aprinter[8]);
  735.         fcol=1;
  736.         lcol=512;
  737.         return;
  738.     }
  739.     copies=atoi(form_read(tree3,PRNCOPY,alertstr));
  740.     if(copies==0)
  741.     {
  742.         form_alert(1,Aprinter[9]);
  743.         copies=1;
  744.         return;
  745.     }
  746.     if(act_dev>=POP21)
  747.     {
  748.         if(tree3[PRNFILE].ob_state&SELECTED)
  749.         {
  750.             make_print_name(alertstr,(char *)Wname(wp),".GEM");
  751.             filename[0]=0;
  752.             strcpy(fpattern,"*.GEM");
  753.             if(getfilename(filename,fpattern,split_fname(alertstr),fselmsg[19]))
  754.             {
  755.                 gdosprint(tree1,tree2,tree3,wp,METAFILE,filename);
  756.             }
  757.         }
  758.         else
  759.         {
  760.             for(m=0; m<copies; m++)
  761.             {
  762.                 sprintf(alertstr,"%d",m+1);
  763.                 form_write(tree1,PRTCOPY,alertstr,FALSE);
  764.                 make_print_name(filename,(char *)Wname(wp),".GEM");
  765.                 if(!gdosprint(tree1,tree2,tree3,wp,v_getdevice(scrollist)/*act_dev-POP21+21*/,filename))
  766.                     break;
  767.             }
  768.         }
  769.     }
  770.     else
  771.     {
  772.         if(tree3[PRNBACK].ob_state&SELECTED)
  773.         {
  774.             make_print_name(filename,(char *)Wname(wp),".PRN");
  775.             if((fp=fopen(filename,"wb"))!=NULL)
  776.             {
  777. #if GEMDOS
  778.                 if(setvbuf(fp,NULL,_IOFBF,32*1024L-1))
  779.                     setvbuf(fp,buff,_IOFBF,sizeof(buff));
  780. #endif
  781.                 draftprint(tree1,tree2,tree3,wp,fp);
  782.                 fclose(fp);
  783.                 spool(filename,copies,tree3[PRNDEL].ob_state&SELECTED?TRUE:FALSE);
  784.             }
  785.             else
  786.                 form_alert(1,Aprinter[10]);
  787.             return;
  788.         }
  789.         if(tree3[PRNFILE].ob_state&SELECTED)
  790.         {
  791.             filename[0]=0;
  792.             strcpy(fpattern,"*.PRN");
  793.             if(getfilename(filename,fpattern,"@",fselmsg[20]))
  794.             {
  795.                 if((fp=fopen(filename,"wb"))!=NULL)
  796.                 {
  797. #if GEMDOS
  798.                     if(setvbuf(fp,NULL,_IOFBF,32*1024L-1))
  799.                         setvbuf(fp,buff,_IOFBF,sizeof(buff));
  800. #endif
  801.                     draftprint(tree1,tree2,tree3,wp,fp);
  802.                     fclose(fp);
  803.                 }
  804.                 else
  805.                     form_alert(1,Aprinter[11]);
  806.             }
  807.             return;
  808.         }
  809.  
  810. #if GEMDOS
  811.         Ongibit(32); /* Deskjet erwache! aber nur einmal, statt in is_busy() */
  812. #endif
  813.         while(!is_busy())
  814.         {
  815.             if(form_alert(2,Aprinter[5])==1)
  816.                 return;
  817. #if GEMDOS
  818.             Ongibit(32); /* Deskjet erwache! aber nur einmal, statt in is_busy() */
  819. #endif
  820.         }
  821.         if(tree3[PRNNOFORM].ob_state&SELECTED)
  822.         {
  823.             for(m=0; m<copies; m++)
  824.             {
  825.                 line=wp->fstr;
  826.                 if(is_busy())
  827.                 {
  828.                     graf_mkstate(&ret, &ret, &ret, &kstate); /* Shifttaste? */
  829.                     do
  830.                     {
  831.                         FPRINTF(stdprn,"\r%s\r\n",line->string);
  832.                         line=line->next;
  833.                     }
  834.                     while(line!=NULL);
  835.                     fflush(stdprn);
  836.                     if(kstate & (K_LSHIFT|K_RSHIFT))        /* bei gedrückter Shifttaste... */
  837.                         FPRINTF(stdprn,"%c",FORMFEED);      /* ...FORMFEED senden */
  838.                 }
  839.                 else
  840.                 {
  841.                     form_alert(1,Aprinter[0]);
  842.                     return;
  843.                 }
  844.             }
  845.         }
  846.         else
  847.         {
  848.             for(m=0; m<copies; m++)
  849.             {
  850.                 sprintf(alertstr,"%d",m+1);
  851.                 form_write(tree1,PRTCOPY,alertstr,FALSE);
  852.                 if(!draftprint(tree1,tree2,tree3,wp,stdprn))
  853.                     break;
  854.             }
  855.         }
  856.     }
  857.     return;
  858. }
  859.  
  860. void spool_file(void)
  861. {
  862.     char filename[PATH_MAX];
  863.     static char fpattern[13]="*.*";
  864.     filename[0]=0;
  865.     if(!getfilename(filename,fpattern,"",fselmsg[21]))
  866.         return;
  867.     spool(filename,1,FALSE);
  868. }
  869.  
  870. #if GEMDOS
  871. static int scan_assignsys(OBJECT *tree, OBJECT *pop)
  872. {
  873.     char *cp/*,devstr[4],assignsys[]="@:\\ASSIGN.SYS"*/;
  874.     int i,first;
  875. /*
  876.     FILE *fp;
  877. */
  878.     int handle,exists;
  879.     char name[33];
  880.     
  881.     scrollist = (TSCROLLIST *)malloc(sizeof(TSCROLLIST));
  882.     memset(scrollist,0,sizeof(TSCROLLIST));
  883.  
  884.     scrollist->count=3;
  885.     
  886.     scrollist->gdosinfo[0].state |= SELECTED;
  887.     scrollist->gdosinfo[0].retcode=1;
  888. #ifdef ENGLISH
  889.     strcpy(scrollist->gdosinfo[0].devname,"  undefinied  ");
  890. #else
  891.     strcpy(scrollist->gdosinfo[0].devname,"  undefiniert ");
  892. #endif
  893.     scrollist->gdosinfo[0].devno=0;
  894.     
  895.     scrollist->gdosinfo[1].retcode=2;
  896.     strcpy(scrollist->gdosinfo[1].devname,"  Epson ESC/P ");
  897.     scrollist->gdosinfo[1].devno=0;
  898.  
  899.     scrollist->gdosinfo[2].retcode=3;
  900.     strcpy(scrollist->gdosinfo[2].devname,"  IBM Pro     ");
  901.     scrollist->gdosinfo[2].devno=0;
  902.     
  903.     if(vq_gdos())
  904.     {
  905.         graf_mouse(BUSY_BEE,NULL);
  906.         first=TRUE;
  907.         for(i=11; (i<100) && (scrollist->count<MAXDEVICES); i++)
  908.         {
  909.             if((handle=open_work(i))>0)
  910.             {
  911.                 if(first && (i>=PRINTER) && (i<=PRINTER+10))
  912.                 {
  913.                     ps[0].w = (int)((long)work_out[0]*(long)work_out[3]/100);
  914.                     ps[0].h = (int)((long)work_out[1]*(long)work_out[4]/100);
  915. /*
  916.                     sprintf((char *)pop[POPBASIS].ob_spec.index,
  917.                                 "  %3d x %3d ",
  918.                                 ps[0].w/10, ps[0].h/10);
  919. */
  920.                     sprintf((char *)tree[PRNPAPER].ob_spec.index,
  921.                                 "  %3d x %3d ",
  922.                                 ps[0].w/10, ps[0].h/10);
  923.  
  924.                     first = FALSE;
  925.                 }
  926.                 scrollist->gdosinfo[scrollist->count].retcode=scrollist->count+1;
  927.                 scrollist->gdosinfo[scrollist->count].devno=i;
  928.                 if(vq_vgdos()==0x5F46534D) /* Abfragbar ab Vektor GDOS */
  929.                 {
  930.                     memset(name,0,sizeof(name));
  931.                     vqt_devinfo(handle,i,&exists,name);
  932.                     if(exists)
  933.                     {
  934.                         if((cp=strrchr(name,'.'))!=NULL) /* '.SYS' weg */
  935.                             *cp=0;
  936.                         sprintf(scrollist->gdosinfo[scrollist->count].devname,"  %2d %-8s  ",i,name);
  937.                     }
  938.                     else
  939.                         sprintf(scrollist->gdosinfo[scrollist->count].devname,"  %2d %-8s  ",i,"GDOS");
  940.                 }
  941.                 else
  942.                     sprintf(scrollist->gdosinfo[scrollist->count].devname,"  %2d %-8s  ",i,"GDOS");
  943.                 scrollist->count++;
  944.                 close_work(handle,i);
  945.             }
  946.         }
  947.         unlink("GEMFILE.GEM");
  948.         graf_mouse(ARROW,NULL);
  949.     }
  950. /*    
  951.     devcount=0;
  952.     assignsys[0]=(char)(getbootdev()+'A');
  953.     if((fp=fopen(assignsys,"r"))!=NULL)
  954.     {
  955.         while(fgets(alertstr,PATH_MAX,fp))
  956.         {
  957.             if(*alertstr != ';') /* Kommentarzeile */
  958.             {
  959.                 for(i=PRINTER; i<METAFILE; i++)
  960.                 {
  961.                     sprintf(devstr,"%2d",i);
  962.                     if(!strncmp(devstr,alertstr,2))
  963.                     {
  964.                         if(tolower(alertstr[2])=='r') /* residenter Treiber */
  965.                             sscanf(&alertstr[4],"%s",&alertstr[100]);
  966.                         else
  967.                             sscanf(&alertstr[3],"%s",&alertstr[100]);
  968.                         strcpy(alertstr,&alertstr[100]);
  969.                         if((cp=strrchr(alertstr,'.'))!=NULL)
  970.                             *(cp+1)=0;
  971.  
  972.                         alertstr[strlen(alertstr)-1]=' ';
  973.                         sprintf((char *)tree[i-PRINTER+POP21].ob_spec.index+5L,
  974.                                   "%-8s",alertstr);
  975.                         devcount++;
  976.                         break;
  977.                     }
  978.                 }
  979.             }
  980.         }
  981.         fclose(fp);
  982.     }
  983. */
  984.     return(scrollist->count);
  985. }
  986. #endif
  987.  
  988. int v_getdevice(TSCROLLIST *list)
  989. {
  990.     int i;
  991.     for(i=3; i<list->count; i++)
  992.         if(list->gdosinfo[i].state & SELECTED)
  993.             return(list->gdosinfo[i].devno);
  994. }
  995.  
  996. static void verify_printable_lines(WINDOW *wp)
  997. {
  998.     int device,i,handle,ret,ch,id,size;
  999.     
  1000.     if(wp && act_dev>=POP21 && vq_gdos())
  1001.     {
  1002.         graf_mouse(BUSY_BEE,NULL);
  1003.         device=v_getdevice(scrollist);
  1004.         if((handle=open_work(device/*act_dev-POP21+PRINTER*/))>0)
  1005.         {
  1006. #if GEMDOS
  1007.             close_work(handle,device/*act_dev-POP21+PRINTER*/);
  1008.             _VDIParBlk.contrl[1] = 1;
  1009.             _VDIParBlk.ptsin [0] = (int)((long)ps[act_paper-POPBASIS/*POPLETT*/].w*100/work_out[3]);
  1010.             _VDIParBlk.ptsin [1] = (int)((long)ps[act_paper-POPBASIS/*POPLETT*/].h*100/work_out[4]);
  1011.             for (i = 0; i < 103; i++) work_in [i] = 1;
  1012.             work_in [0]  = device/*act_dev-POP21+PRINTER*/;                /* Devicehandle */
  1013.             work_in [10] = 2;                                  /* Raster Koordinaten */
  1014.             work_in [11] = 255;         /* OW_NOCHANGE parallel or serial port */
  1015.             _V_opnwk (work_in, &handle, work_out);     /* physikalisch öffnen */
  1016. #endif
  1017.          if(vq_vgdos()==0x5F46534D)
  1018.             vst_scratch(handle,2); /* FSM Scratchbuffer auf null, sonst geht nicht */
  1019.             vst_load_fonts(handle,0);                                 /* Fonts laden */
  1020.             id=vst_font(handle,wp->fontid);                             /* Font wählen */
  1021.             size=vst_point(handle,wp->fontsize,&ret,&ret,&ret,&ch);          /* pts */
  1022.             if(id!=wp->fontid || size!=wp->fontsize)
  1023.                 form_alert(1,Aprinter[15]);         /* Warnung ausgeben */
  1024.             else
  1025.             {
  1026.                 if(act_dist==POPD1)
  1027.                     bl=min(bl,(int)((long)ps[act_paper-POPBASIS/*POPLETT*/].h*100/work_out[4]/ch-UNPRINTABLE_LINES));
  1028.                 if(act_dist==POPD1+1)
  1029.                     bl=min(bl,(int)((long)ps[act_paper-POPBASIS/*POPLETT*/].h*100/work_out[4]/ch-UNPRINTABLE_LINES)*2/3);
  1030.                 if(act_dist==POPD1+2)
  1031.                     bl=min(bl,(int)((long)ps[act_paper-POPBASIS/*POPLETT*/].h*100/work_out[4]/ch-UNPRINTABLE_LINES)/2);
  1032.             }
  1033.             vst_unload_fonts(handle,0);                         /* Fonts freigeben */
  1034.             close_work(handle,device/*act_dev-POP21+PRINTER*/);
  1035.         }
  1036.         graf_mouse(ARROW,NULL);
  1037.     }
  1038.     return;
  1039. }
  1040.  
  1041. void hndl_layout(OBJECT *tree, int start)
  1042. {
  1043.     int id,pt,i,handle,x,y,mx,my,ret,ch,exit_obj,done=FALSE;
  1044.     static int first=TRUE;
  1045.     WINDOW *wp;
  1046.     char str1[31],str2[31],str3[FILENAME_MAX],
  1047.          *cp,pathname[PATH_MAX],filename[13];
  1048.     int A,B,C,D,E,F,G,H,I,J,K,L,M,N;
  1049.     /*static*/ char fpattern[FILENAME_MAX]="*.LAY";
  1050.     
  1051. /*
  1052.     extern int windials;
  1053. */
  1054.     graf_mouse(BUSY_BEE,0L);
  1055.     wp=Wgettop();
  1056.     if(first)
  1057.     {
  1058.         search_env(pathname,"7UP.LAY",FALSE); /* READ */
  1059.         if(fexist(pathname)/* 23.10.94 shel_find(pathname)*/)
  1060.         {
  1061.             form_write(tree,PRNLAY,(char *)split_fname(pathname),FALSE);
  1062.             loadformat(tree,pathname);
  1063.         }
  1064.         else
  1065.             form_write(tree,PRNLAY,"",FALSE);
  1066. #if GEMDOS
  1067.         if(!scrollist)
  1068.             scan_assignsys(tree, gdospop);
  1069.         strcpy((char *)tree[PRNDRUCK].ob_spec.index, 
  1070.             scrollist->gdosinfo[POPNO-1].devname);
  1071.  
  1072. /*
  1073.         if(vq_gdos())
  1074.             i=scan_assignsys(gdospop)+PRINTER;
  1075.         else
  1076.             i=PRINTER;
  1077.         gdospop->ob_height=3*boxh+(i-PRINTER)*boxh;
  1078.  
  1079.         if(act_dev>gdospop->ob_height/boxh)
  1080.             act_dev=POPNO;
  1081.         if(act_dev>POPIBM && !vq_gdos()) /* Kein GDOS mehr da */
  1082.             act_dev=POPNO;
  1083.         if(act_dist>POPD1 && !vq_gdos()) /* Kein GDOS mehr da */
  1084.             act_dist=POPD1;
  1085.         if(act_dev>POPIBM)                    /* Zeilenzahl einstellen */
  1086.             verify_printable_lines(wp);
  1087.  
  1088.         gdospop [act_dev  ].ob_state|=CHECKED;
  1089.         strcpy((char *)tree[PRNDRUCK].ob_spec.index,
  1090.                  (char *)gdospop[act_dev].ob_spec.index);
  1091. */
  1092. #else
  1093.         gdospop->ob_height=3*boxh;
  1094. #endif
  1095.         first=FALSE;
  1096.     }
  1097.  
  1098.     if(wp)                             /* Falls Fenster offen... */
  1099.     {
  1100.         strcpy(filename,split_fname((char *)Wname(wp)));
  1101.         change_ext(filename,".LAY");
  1102.         search_env(pathname,filename,FALSE); /* READ */
  1103.         if(fexist(pathname)/* 23.10.94 shel_find(pathname)*/)
  1104.         {
  1105.             form_write(tree,PRNLAY,(char *)split_fname(pathname),FALSE);
  1106.             loadformat(tree,pathname);
  1107.         }
  1108.     }
  1109.  
  1110.     sprintf(tree[PRNZL].ob_spec.tedinfo->te_ptext,"%3d", A=zl);
  1111.     sprintf(tree[PRNBL].ob_spec.tedinfo->te_ptext,"%3d", B=bl);
  1112.     sprintf(tree[PRNOR].ob_spec.tedinfo->te_ptext,"%02d",C=or);
  1113.     sprintf(tree[PRNKZ].ob_spec.tedinfo->te_ptext,"%02d",D=kz);
  1114.     sprintf(tree[PRNFZ].ob_spec.tedinfo->te_ptext,"%02d",E=fz);
  1115.     sprintf(tree[PRNUR].ob_spec.tedinfo->te_ptext,"%02d",F=ur);
  1116.     sprintf(tree[PRNLR].ob_spec.tedinfo->te_ptext,"%02d",G=lr);
  1117.     sprintf(tree[PRNZZ].ob_spec.tedinfo->te_ptext,"%3d", H=zz);
  1118.     I=tree[PRNKZL].ob_state;
  1119.     J=tree[PRNKZM].ob_state;
  1120.     K=tree[PRNKZR].ob_state;
  1121.     L=tree[PRNFZL].ob_state;
  1122.     M=tree[PRNFZM].ob_state;
  1123.     N=tree[PRNFZR].ob_state;
  1124.     form_read(tree,PRNKZSTR,str1);
  1125.     form_read(tree,PRNFZSTR,str2);
  1126.     form_read(tree,PRNLAY,str3);
  1127.  
  1128.     if(act_dev<POP21)
  1129.     {
  1130.         tree[PRNPAPER].ob_state|=DISABLED;
  1131.         tree[PRNCIRC1].ob_state|=DISABLED;
  1132.         tree[PRNDIST ].ob_state|=DISABLED;
  1133.         tree[PRNCIRC3].ob_state|=DISABLED;
  1134.         tree[PRNPAPER].ob_flags&=~TOUCHEXIT;
  1135.         tree[PRNCIRC1].ob_flags&=~TOUCHEXIT;
  1136.         tree[PRNDIST ].ob_flags&=~TOUCHEXIT;
  1137.         tree[PRNCIRC3].ob_flags&=~TOUCHEXIT;
  1138.     }
  1139.     else
  1140.     {
  1141.         tree[PRNPAPER].ob_state&=~DISABLED;
  1142.         tree[PRNCIRC1].ob_state&=~DISABLED;
  1143.         tree[PRNDIST ].ob_state&=~DISABLED;
  1144.         tree[PRNCIRC3].ob_state&=~DISABLED;
  1145.         tree[PRNPAPER].ob_flags|=TOUCHEXIT;
  1146.         tree[PRNCIRC1].ob_flags|=TOUCHEXIT;
  1147.         tree[PRNDIST ].ob_flags|=TOUCHEXIT;
  1148.         tree[PRNCIRC3].ob_flags|=TOUCHEXIT;
  1149.     }
  1150.  
  1151.     graf_mouse(ARROW,0L);
  1152.  
  1153.     form_exopen(tree,0);
  1154.     do
  1155.     {
  1156.         exit_obj=(form_exdo(tree,start)&0x7FFF);
  1157.         switch(exit_obj)
  1158.         {
  1159.             case PRNPAPER:
  1160.                 graf_mkstate(&mx,&my,&ret,&ret);
  1161.                 objc_offset(tree,PRNPAPER,&x,&y);
  1162.                 mx=x+tree[PRNPAPER].ob_width/2;
  1163.                 my=y+(POPWIDE-POPBASIS+1)*boxh/2-(act_paper-POPBASIS/*POPLETT*/)*boxh;
  1164.                 switch(ret=pop_exhndl(paperpop,mx,my,TRUE))
  1165.                 {
  1166.                     case POPBASIS:
  1167.                     case POPLETT :
  1168.                     case POPLEGA :
  1169.                     case POPHALF :
  1170.                     case POPLEDG :
  1171.                     case POPA3    :
  1172.                     case POPA4    :
  1173.                     case POPA5    :
  1174.                     case POPB5    :
  1175.                     case POPWIDE :
  1176.                         if(ret!=act_paper)
  1177.                         {
  1178.                             paperpop[act_paper].ob_state&=~CHECKED;
  1179.                             act_paper=ret;
  1180.                             paperpop[act_paper].ob_state|=CHECKED;
  1181. /*
  1182.                             strcpy((char *)tree[PRNPAPER].ob_spec.index,
  1183.                                      (char *)paperpop[ret].ob_spec.index);
  1184. */
  1185.                             sprintf((char *)tree[PRNPAPER].ob_spec.index,
  1186.                                         "  %3d x %3d ",
  1187.                                         ps[act_paper-1].w/10, ps[act_paper-1].h/10);
  1188.  
  1189.                        objc_draw(tree,PRNPAPER,0,x,y,
  1190.                                    tree[PRNPAPER].ob_width-1,tree[PRNPAPER].ob_height);
  1191. /*
  1192.                             objc_update(tree,PRNPAPER,0);
  1193. */
  1194.                             verify_printable_lines(wp);
  1195.                             goto BL;
  1196.                         }
  1197.                 }
  1198.                 break;
  1199.             case PRNCIRC1:
  1200.                 objc_offset(tree,PRNPAPER,&x,&y);
  1201.                 paperpop[act_paper].ob_state&=~CHECKED;
  1202.                 if(++act_paper>POPWIDE)
  1203.                     act_paper=POPBASIS/*POPLETT*/;
  1204.                 paperpop[act_paper].ob_state|=CHECKED;
  1205.                 strcpy((char *)tree[PRNPAPER].ob_spec.index,
  1206.                          (char *)paperpop[act_paper].ob_spec.index);
  1207.                 objc_draw(tree,PRNPAPER,0,x,y,
  1208.                     tree[PRNPAPER].ob_width-1,tree[PRNPAPER].ob_height);
  1209.                 objc_update(tree,PRNPAPER,0);
  1210.                 verify_printable_lines(wp);
  1211.                 evnt_timer(125,0);
  1212.                 goto BL;
  1213.                 break;
  1214.             case PRNCIRC2:
  1215.             case PRNDRUCK:
  1216.                 graf_mkstate(&mx,&my,&ret,&ret);
  1217.                 objc_offset(tree,PRNDRUCK,&x,&y);
  1218.                 ret=listbox_hndl(tree,PRNDRUCK,scrollist);
  1219.  
  1220.                 /*MT 11.5.95 weil kein TOUCHEXIT mehr*/
  1221.                 objc_change(tree,exit_obj,0,tree->ob_x,tree->ob_y,
  1222.                     tree->ob_width,tree->ob_height,
  1223.                     tree[exit_obj].ob_state&~SELECTED,TRUE);
  1224.  
  1225.                 if((ret!=-1) && (act_dev!=ret))
  1226.             {
  1227.                act_dev=ret;
  1228.                     strcpy((char *)tree[PRNDRUCK].ob_spec.index, 
  1229.                         scrollist->gdosinfo[ret-1].devname);
  1230.                objc_draw(tree,PRNDRUCK,0,x,y,
  1231.                   tree[PRNDRUCK].ob_width-1,tree[PRNDRUCK].ob_height);
  1232.  
  1233.                     if(act_dev<POP21)
  1234.                     {
  1235.                         tree[PRNPAPER].ob_state|=DISABLED;
  1236.                         tree[PRNCIRC1].ob_state|=DISABLED;
  1237.                         tree[PRNDIST ].ob_state|=DISABLED;
  1238.                         tree[PRNCIRC3].ob_state|=DISABLED;
  1239.                         tree[PRNPAPER].ob_flags&=~TOUCHEXIT;
  1240.                         tree[PRNCIRC1].ob_flags&=~TOUCHEXIT;
  1241.                         tree[PRNDIST ].ob_flags&=~TOUCHEXIT;
  1242.                         tree[PRNCIRC3].ob_flags&=~TOUCHEXIT;
  1243.                     }
  1244.                     else
  1245.                     {
  1246.                         tree[PRNPAPER].ob_state&=~DISABLED;
  1247.                         tree[PRNCIRC1].ob_state&=~DISABLED;
  1248.                         tree[PRNDIST ].ob_state&=~DISABLED;
  1249.                         tree[PRNCIRC3].ob_state&=~DISABLED;
  1250.                         tree[PRNPAPER].ob_flags|=TOUCHEXIT;
  1251.                         tree[PRNCIRC1].ob_flags|=TOUCHEXIT;
  1252.                         tree[PRNDIST ].ob_flags|=TOUCHEXIT;
  1253.                         tree[PRNCIRC3].ob_flags|=TOUCHEXIT;
  1254.                     }
  1255.                     objc_update(tree,PRNPAPER,0);
  1256.                     objc_update(tree,PRNCIRC1,0);
  1257.                     objc_update(tree,PRNDIST,0);
  1258.                     objc_update(tree,PRNCIRC3,0);
  1259.                     verify_printable_lines(wp);
  1260.                     goto BL;
  1261.             }
  1262. /*
  1263.                 graf_mkstate(&mx,&my,&ret,&ret);
  1264.                 objc_offset(tree,PRNDRUCK,&x,&y);
  1265.                 mx=x+tree[PRNDRUCK].ob_width/2;
  1266.                 my=y+gdospop->ob_height/2-(act_dev-POPNO)*boxh;
  1267.                 switch(ret=pop_exhndl(gdospop,mx,my,TRUE))
  1268.                 {
  1269.                     case POPNO:
  1270.                     case POPEPS:
  1271.                     case POPIBM:
  1272.                     case POP21:
  1273.                     case POP22:
  1274.                     case POP23:
  1275.                     case POP24:
  1276.                     case POP25:
  1277.                     case POP26:
  1278.                     case POP27:
  1279.                     case POP28:
  1280.                     case POP29:
  1281.                     case POP30:
  1282.                         if(ret!=act_dev)
  1283.                         {
  1284.                             gdospop[act_dev].ob_state&=~CHECKED;
  1285.                             act_dev=ret;
  1286.                             gdospop[act_dev].ob_state|=CHECKED;
  1287.                             strcpy((char *)tree[PRNDRUCK].ob_spec.index,
  1288.                                      (char *)gdospop[ret].ob_spec.index);
  1289.                             objc_update(tree,PRNDRUCK,0);
  1290.                             if(act_dev<POP21)
  1291.                             {
  1292.                                 tree[PRNPAPER].ob_state|=DISABLED;
  1293.                                 tree[PRNCIRC1].ob_state|=DISABLED;
  1294.                                 tree[PRNDIST ].ob_state|=DISABLED;
  1295.                                 tree[PRNCIRC3].ob_state|=DISABLED;
  1296.                                 tree[PRNPAPER].ob_flags&=~TOUCHEXIT;
  1297.                                 tree[PRNCIRC1].ob_flags&=~TOUCHEXIT;
  1298.                                 tree[PRNDIST ].ob_flags&=~TOUCHEXIT;
  1299.                                 tree[PRNCIRC3].ob_flags&=~TOUCHEXIT;
  1300.                             }
  1301.                             else
  1302.                             {
  1303.                                 tree[PRNPAPER].ob_state&=~DISABLED;
  1304.                                 tree[PRNCIRC1].ob_state&=~DISABLED;
  1305.                                 tree[PRNDIST ].ob_state&=~DISABLED;
  1306.                                 tree[PRNCIRC3].ob_state&=~DISABLED;
  1307.                                 tree[PRNPAPER].ob_flags|=TOUCHEXIT;
  1308.                                 tree[PRNCIRC1].ob_flags|=TOUCHEXIT;
  1309.                                 tree[PRNDIST ].ob_flags|=TOUCHEXIT;
  1310.                                 tree[PRNCIRC3].ob_flags|=TOUCHEXIT;
  1311.                             }
  1312.                             objc_update(tree,PRNPAPER,0);
  1313.                             objc_update(tree,PRNCIRC1,0);
  1314.                             objc_update(tree,PRNDIST,0);
  1315.                             objc_update(tree,PRNCIRC3,0);
  1316.                             verify_printable_lines(wp);
  1317.                             goto BL;
  1318.                         }
  1319.                 }
  1320. */
  1321.                 break;
  1322. /*
  1323.             case PRNCIRC2:
  1324.                 gdospop[act_dev].ob_state&=~CHECKED;
  1325.                 if(++act_dev>(POPNO+gdospop->ob_height/boxh)-1)
  1326.                     act_dev=POPNO;
  1327.                 gdospop[act_dev].ob_state|=CHECKED;
  1328.                 strcpy((char *)tree[PRNDRUCK].ob_spec.index,
  1329.                          (char *)gdospop[act_dev].ob_spec.index);
  1330.  
  1331.                 objc_update(tree,PRNDRUCK,0);
  1332.                 if(act_dev<POP21)
  1333.                 {
  1334.                     tree[PRNPAPER].ob_state|=DISABLED;
  1335.                     tree[PRNCIRC1].ob_state|=DISABLED;
  1336.                     tree[PRNDIST ].ob_state|=DISABLED;
  1337.                     tree[PRNCIRC3].ob_state|=DISABLED;
  1338.                     tree[PRNPAPER].ob_flags&=~TOUCHEXIT;
  1339.                     tree[PRNCIRC1].ob_flags&=~TOUCHEXIT;
  1340.                     tree[PRNDIST ].ob_flags&=~TOUCHEXIT;
  1341.                     tree[PRNCIRC3].ob_flags&=~TOUCHEXIT;
  1342.                 }
  1343.                 else
  1344.                 {
  1345.                     tree[PRNPAPER].ob_state&=~DISABLED;
  1346.                     tree[PRNCIRC1].ob_state&=~DISABLED;
  1347.                     tree[PRNDIST ].ob_state&=~DISABLED;
  1348.                     tree[PRNCIRC3].ob_state&=~DISABLED;
  1349.                     tree[PRNPAPER].ob_flags|=TOUCHEXIT;
  1350.                     tree[PRNCIRC1].ob_flags|=TOUCHEXIT;
  1351.                     tree[PRNDIST ].ob_flags|=TOUCHEXIT;
  1352.                     tree[PRNCIRC3].ob_flags|=TOUCHEXIT;
  1353.                 }
  1354.                 objc_update(tree,PRNPAPER,0);
  1355.                 objc_update(tree,PRNCIRC1,0);
  1356.                 objc_update(tree,PRNDIST,0);
  1357.                 objc_update(tree,PRNCIRC3,0);
  1358.                 verify_printable_lines(wp);
  1359.                 evnt_timer(125,0);
  1360.                 goto BL;
  1361.                 break;
  1362. */
  1363.             case PRNDIST:
  1364.                 graf_mkstate(&mx,&my,&ret,&ret);
  1365.                 objc_offset(tree,PRNDIST,&x,&y);
  1366.                 mx=x+tree[PRNDIST].ob_width/2;
  1367.                 my=y+3*boxh/2-(act_dist-POPD1)*boxh;
  1368.                 switch(ret=pop_exhndl(distpop,mx,my,TRUE))
  1369.                 {
  1370.                     case POPD1:
  1371.                     case POPD1+1:
  1372.                     case POPD1+2:
  1373.                         if(ret!=act_dist)
  1374.                         {
  1375.                             distpop[act_dist].ob_state&=~CHECKED;
  1376.                             act_dist=ret;
  1377.                             distpop[act_dist].ob_state|=CHECKED;
  1378.                             strcpy((char *)tree[PRNDIST].ob_spec.index,
  1379.                                      (char *)distpop[ret].ob_spec.index);
  1380.                        objc_draw(tree,PRNDIST,0,x,y,
  1381.                                    tree[PRNDIST].ob_width-1,tree[PRNDIST].ob_height);
  1382.                             objc_update(tree,PRNDIST,0);
  1383.                             verify_printable_lines(wp);
  1384.                             goto BL;
  1385.                         }
  1386.                 }
  1387.                 break;
  1388.             case PRNCIRC3:
  1389.                 objc_offset(tree,PRNDIST,&x,&y);
  1390.                 distpop[act_dist].ob_state&=~CHECKED;
  1391.                 if(++act_dist>(POPD1+2))
  1392.                     act_dist=POPD1;
  1393.                 distpop[act_dist].ob_state|=CHECKED;
  1394.                 strcpy((char *)tree[PRNDIST].ob_spec.index,
  1395.                          (char *)distpop[act_dist].ob_spec.index);
  1396.                 objc_draw(tree,PRNDIST,0,x,y,
  1397.                              tree[PRNDIST].ob_width-1,tree[PRNDIST].ob_height);
  1398. /*
  1399.                 objc_update(tree,PRNDIST,0);
  1400. */
  1401.                 verify_printable_lines(wp);
  1402.                 evnt_timer(125,0);
  1403.                 goto BL;
  1404.                 break;
  1405.             case PRNZLDN:
  1406.                 if(--zl<32)
  1407.                     zl=32;
  1408.                 goto LR;
  1409.                 break;
  1410.             case PRNZLUP:
  1411.                 if(++zl>256)
  1412.                     zl=256;
  1413.                 goto LR;
  1414.                 break;
  1415.             case PRNLRDN:
  1416.                 if(--lr<0)
  1417.                     lr=0;
  1418.                 else
  1419.                     zl++;
  1420.                 goto LR;
  1421.                 break;
  1422.             case PRNLRUP:
  1423.                 if(++lr>32)
  1424.                     lr=32;
  1425.                 else
  1426.                     zl--;
  1427. LR:
  1428.         sprintf(tree[PRNZL].ob_spec.tedinfo->te_ptext,"%3d",zl);
  1429.         objc_update(tree, PRNZL, 0);
  1430.         sprintf(tree[PRNLR].ob_spec.tedinfo->te_ptext,"%02d",lr);
  1431.         objc_update(tree, PRNLR, 0);
  1432.                 break;
  1433.             case PRNBLDN:
  1434.                 if(--bl<32)
  1435.                     bl=32;
  1436.                 goto BL;
  1437.                 break;
  1438.             case PRNBLUP:
  1439.                 if(++bl>136)
  1440.                     bl=136;
  1441. BL:
  1442.         sprintf(tree[PRNBL].ob_spec.tedinfo->te_ptext,"%3d",bl);
  1443.         objc_update(tree, PRNBL, 0);
  1444.                 break;
  1445.             case PRNORDN:
  1446.                 if(--or<0)
  1447.                     or=0;
  1448.                 goto OR;
  1449.                 break;
  1450.             case PRNORUP:
  1451.                 if(++or>8)
  1452.                     or=8;
  1453. OR:
  1454.         sprintf(tree[PRNOR].ob_spec.tedinfo->te_ptext,"%02d",or);
  1455.         objc_update(tree, PRNOR, 0);
  1456.                 break;
  1457.             case PRNKZDN:
  1458.                 if(--kz<0)
  1459.                     kz=0;
  1460.                 goto KZ;
  1461.                 break;
  1462.             case PRNKZUP:
  1463.                 if(++kz>8)
  1464.                     kz=8;
  1465. KZ:
  1466.         sprintf(tree[PRNKZ].ob_spec.tedinfo->te_ptext,"%02d",kz);
  1467.         objc_update(tree, PRNKZ, 0);
  1468.                 break;
  1469.             case PRNFZDN:
  1470.                 if(--fz<0)
  1471.                     fz=0;
  1472.                 goto FZ;
  1473.                 break;
  1474.             case PRNFZUP:
  1475.                 if(++fz>8)
  1476.                     fz=8;
  1477. FZ:
  1478.         sprintf(tree[PRNFZ].ob_spec.tedinfo->te_ptext,"%02d",fz);
  1479.         objc_update(tree, PRNFZ, 0);
  1480.                 break;
  1481.             case PRNURDN:
  1482.                 if(--ur<0)
  1483.                     ur=0;
  1484.                 goto UR;
  1485.                 break;
  1486.             case PRNURUP:
  1487.                 if(++ur>8)
  1488.                     ur=8;
  1489. UR:
  1490.         sprintf(tree[PRNUR].ob_spec.tedinfo->te_ptext,"%02d",ur);
  1491.         objc_update(tree, PRNUR, 0);
  1492.                 break;
  1493.             case PRNHELP:
  1494.                 if(form_alert(2,Aprinter[12])==2)
  1495.                     form_alert(1,Aprinter[13]);
  1496.                 objc_change(tree,exit_obj,0,tree->ob_x,tree->ob_y,tree->ob_width,tree->ob_height,tree[exit_obj].ob_state&~SELECTED,TRUE);
  1497.                 break;
  1498.             case PRNLOAD:
  1499.                 alertstr[0]=0;
  1500.                 search_env(alertstr,fpattern,FALSE); /* READ */
  1501. /* 29.5.94 */
  1502.                 if( ! (strrchr(alertstr,'\\') || strrchr(alertstr,'/')))
  1503.                     *alertstr=0;
  1504.                 if(getfilename(alertstr,fpattern,"@",fselmsg[22]))
  1505.                 {
  1506.                     graf_mouse(BUSY_BEE,0L);
  1507.                     form_write(tree,PRNLAY,(char *)split_fname(alertstr),TRUE);
  1508.                     loadformat(tree,alertstr);
  1509.                     objc_update(tree,PRNKZSTR,0);
  1510.                     objc_update(tree,PRNFZSTR,0);
  1511.                     objc_update(tree,PRNKZM,0);
  1512.                     objc_update(tree,PRNKZR,0);
  1513.                     objc_update(tree,PRNFZL,0);
  1514.                     objc_update(tree,PRNFZM,0);
  1515.                     objc_update(tree,PRNFZR,0);
  1516.                     objc_update(tree,PRNZL,0);
  1517.                     objc_update(tree,PRNBL,0);
  1518.                     objc_update(tree,PRNOR,0);
  1519.                     objc_update(tree,PRNKZ,0);
  1520.                     objc_update(tree,PRNFZ,0);
  1521.                     objc_update(tree,PRNUR,0);
  1522.                     objc_update(tree,PRNLR,0);
  1523.                     objc_update(tree,PRNZZ,0);
  1524.                     graf_mouse(ARROW,0L);
  1525.                 }
  1526.                 tree[exit_obj].ob_state&=~SELECTED;
  1527.                 if(!windials)
  1528.                     objc_update(tree,ROOT,MAX_DEPTH);
  1529.                 else
  1530.                     objc_update(tree,exit_obj,0);
  1531.                 break;
  1532.             case PRNSAVE:
  1533.                 alertstr[0]=0;
  1534.                 search_env(alertstr,fpattern,TRUE); /* SAVE */
  1535. /* 29.5.94 */
  1536.                 if( ! (strrchr(alertstr,'\\') || strrchr(alertstr,'/')))
  1537.                     *alertstr=0;
  1538.                 if(getfilename(alertstr,fpattern,"@",fselmsg[23]))
  1539.                 {
  1540.                     graf_mouse(BUSY_BEE,0L);
  1541.                     form_write(tree,PRNLAY,(char *)split_fname(alertstr),TRUE);
  1542.                     saveformat(tree,alertstr);
  1543.                     graf_mouse(ARROW,0L);
  1544.                 }
  1545.                 tree[exit_obj].ob_state&=~SELECTED;
  1546.                 if(!windials)
  1547.                     objc_update(tree,ROOT,MAX_DEPTH);
  1548.                 else
  1549.                     objc_update(tree,exit_obj,0);
  1550.                 break;
  1551.             case PRNABBR:
  1552.             case PRNOK:
  1553.                 done=TRUE;
  1554.                 break;
  1555.         }
  1556.         zz=bl-or-kz-fz-ur;
  1557.         sprintf(tree[PRNZZ].ob_spec.tedinfo->te_ptext,"%3d",zz);
  1558.         objc_update(tree, PRNZZ, 0);
  1559.     }
  1560.     while(!done);
  1561.     form_exclose(tree,exit_obj,0);
  1562.  
  1563.     if(exit_obj==PRNABBR)
  1564.     {
  1565.         zl=A;
  1566.         bl=B;
  1567.         or=C;
  1568.         kz=D;
  1569.         fz=E;
  1570.         ur=F;
  1571.         lr=G;
  1572.         zz=H;
  1573.         tree[PRNKZL].ob_state=I;
  1574.         tree[PRNKZM].ob_state=J;
  1575.         tree[PRNKZR].ob_state=K;
  1576.         tree[PRNFZL].ob_state=L;
  1577.         tree[PRNFZM].ob_state=M;
  1578.         tree[PRNFZR].ob_state=N;
  1579.         form_write(tree,PRNKZSTR,str1,0);
  1580.         form_write(tree,PRNFZSTR,str2,0);
  1581.         form_write(tree,PRNLAY,str3,0);
  1582.     }
  1583. }
  1584.  
  1585. #define VM_PAGESIZE 0
  1586. #define VM_COORDS    1
  1587.  
  1588. #if GEMDOS /* sind ab GEM 2.X in den Bindings */
  1589.  
  1590. static void _V_opnwk(int work_in[], int *handle, int work_out[])
  1591. {
  1592.     VDIPB vdipb=
  1593.     {
  1594.         _VDIParBlk.contrl,
  1595.         _VDIParBlk.intin,
  1596.         _VDIParBlk.ptsin,
  1597.         _VDIParBlk.intout,
  1598.         _VDIParBlk.ptsout
  1599.     };
  1600.     
  1601.     memmove(_VDIParBlk.intin,work_in,11*sizeof(int));
  1602.     _VDIParBlk.contrl[0] = 1;
  1603. /*    _VDIParBlk.contrl[1] = 0; */
  1604.     _VDIParBlk.contrl[3] = 11;
  1605.  
  1606.     vdi(&vdipb);
  1607.     *handle = _VDIParBlk.contrl[6];
  1608.  
  1609.     memmove(work_out,_VDIParBlk.intout,45*sizeof(int));
  1610.     memmove(&work_out[45],_VDIParBlk.ptsout,12*sizeof(int));
  1611. }
  1612.  
  1613. #else
  1614.  
  1615. int vq_gdos(void)
  1616. {
  1617.     return(1);
  1618. }
  1619.  
  1620. #endif
  1621.  
  1622. static int v_gdosprt(OBJECT *tree1, OBJECT *tree2, OBJECT *tree3, WINDOW *wp, int handle)
  1623. {
  1624.     register LINESTRUCT *line;
  1625.     int i,k,m,pages,ret,blanks,inrange,mouse_click;
  1626.     long lines,chars,count=1;
  1627.     char c1,c2,*str;
  1628.     int event,wh,result=TRUE;
  1629.     int save,x,y,cw,cw1,cw2,ch,maxlines,oldeffect=TXT_NORMAL;
  1630.  
  1631.     extern int dial_handle;
  1632.  
  1633.     save=handle;                                                      /* Filepointer retten */
  1634.     form_write(tree1,PRTNAME,(char *)Wname(wp),FALSE);
  1635.     form_write(tree1,PRTPAGE,"",FALSE);
  1636.     tree1[ROOT+1].ob_flags|=HIDETREE;
  1637.     
  1638.     form_exopen(tree1,FALSE);
  1639.     
  1640.     vst_point(handle,wp->fontsize,&ret,&ret,&ret,&ch); /* pts */
  1641.     vqt_width(handle,'W',&cw1,&ret,&ret);  /* Breite der Zeichen */
  1642.     vqt_width(handle,'I',&cw2,&ret,&ret);  /* Breite der Zeichen */
  1643.     cw=(cw1+cw2)/2;
  1644.     if(act_dist==POPD1)    /* Zeilenabstand = 1    */
  1645.         ch=ch;
  1646.     if(act_dist==POPD1+1) /* Zeilenabstand = 1.5 */
  1647.         ch=ch*3/2;
  1648.     if(act_dist==POPD1+2) /* Zeilenabstand = 2    */
  1649.         ch=ch*2;
  1650. #if GEMDOS
  1651. #else
  1652.     ch*=3;
  1653.     ch+=X_MIN;
  1654. #endif
  1655.     Wtxtsize(wp,&lines,&chars);
  1656.     pages=lines%zz ? (lines/zz)+1 : lines/zz;            /* Anzahl der Seiten */
  1657.     line=wp->fstr;
  1658.     for(i=0; i<pages; i++)                              /* für jede Seite */
  1659.     {
  1660.         event=evnt_event(&mevent);
  1661. /*
  1662.         wind_update(BEG_UPDATE);
  1663. */
  1664.         if(event & MU_MESAG)
  1665.         {
  1666.             if((msgbuf[0] != MN_SELECTED) && (msgbuf[0] < 50)) /* AP_TERM */
  1667.             {
  1668.                 if(msgbuf[3]==dial_handle) /* Dialogfenster */
  1669.                 {
  1670.                     switch(msgbuf[0])
  1671.                     {
  1672.                         case WM_BACKDROPPED: /* nein, niemals */
  1673.                             break;
  1674.                         case WM_REDRAW:
  1675.                             fwind_redraw(tree1,msgbuf[3],&msgbuf[4]);
  1676.                             break;
  1677.                         case WM_MOVED:
  1678.                             fwind_move(tree1,msgbuf[3],&msgbuf[4]);
  1679.                             break;
  1680.                         case WM_TOPPED:
  1681.                             wind_set(msgbuf[3],WF_TOP,0,0,0,0);
  1682.                             break;
  1683.                     }
  1684.                 }
  1685.                 else /* aber kein Schlieβen oder Toppen */
  1686.                     if(msgbuf[0]!=WM_CLOSED && msgbuf[0]!=WM_TOPPED)
  1687.                         Wwindmsg(Wp(msgbuf[3]),msgbuf);
  1688.             }
  1689.         }
  1690.         if(event&MU_KEYBD || event&MU_BUTTON)
  1691.         {
  1692.             if((mevent.e_kr>>8)==ESC ||                             /* ESC gedrückt? */
  1693.                  objc_find(tree1,ROOT,MAX_DEPTH,mevent.e_mx,mevent.e_my)==PRTESC)
  1694.             {
  1695.                 objc_change(tree1,PRTESC,0,tree1->ob_x,tree1->ob_y,
  1696.                                                     tree1->ob_width,tree1->ob_height,
  1697.                                                     tree1[PRTESC].ob_state|SELECTED,TRUE);
  1698.                 if(form_alert(2,Aprinter[4])==2)
  1699.                 {
  1700. /*
  1701.                     wind_update(END_UPDATE);
  1702. */
  1703.                     result=FALSE;
  1704.                     goto ENDE;
  1705.                 }
  1706.                 objc_change(tree1,PRTESC,0,tree1->ob_x,tree1->ob_y,
  1707.                                                     tree1->ob_width,tree1->ob_height,
  1708.                                                     tree1[PRTESC].ob_state&~SELECTED,TRUE);
  1709.             }
  1710.         }
  1711. /*
  1712.         wind_update(END_UPDATE);
  1713. */
  1714.         x=X_MIN;
  1715.         y=Y_MIN;
  1716.         if(i+1+pageoffset <fpage)                              /* von, bis drucken */
  1717.         {
  1718.             handle=0;
  1719.             inrange=FALSE;
  1720.         }
  1721.         else
  1722.         {
  1723.             handle=save;
  1724.             inrange=TRUE;
  1725.         }
  1726.         if(i+1+pageoffset >lpage)
  1727.         {
  1728.             goto ENDE;
  1729.         }
  1730.         if(handle)
  1731.         {
  1732.             vst_alignment(handle,0,5,&ret,&ret);    /* Ausrichtung */
  1733.             vst_rotation(handle,0);                     /* Winkel 0 */
  1734.             vswr_mode(handle,MD_REPLACE);             /* replace */
  1735.             vst_color(handle,BLACK);                    /* Farbe */
  1736.             vst_effects(handle,0);                      /* keine Attribute */
  1737.         }
  1738.         if(inrange && !(tree3[PRNALLP].ob_state&SELECTED)) /* wenn nicht alle Seiten */
  1739.         {
  1740.             if(tree3[PRNPAIR].ob_state&SELECTED)          /* nur gerade Seiten */
  1741.             {
  1742.                 if((i+1+pageoffset)%2)                      /* bei ungerade weiter */
  1743.                     handle=0;
  1744.                 else
  1745.                     handle=save;
  1746.             }
  1747.             else                                                  /* nur ungerade Seiten */
  1748.             {
  1749.                 if(!((i+1+pageoffset)%2))                     /* bei gerade weiter */
  1750.                     handle=0;
  1751.                 else
  1752.                     handle=save;
  1753.             }
  1754.         }
  1755.         if(handle)
  1756.         {
  1757.             sprintf(alertstr,"%d",i+1);                 /* Seitennummer anzeigen */
  1758.             form_write(tree1,PRTPAGE,alertstr,TRUE);
  1759.         }
  1760.         y+=(or*ch);                                                         /* oberer Rand */
  1761.         if(kz)                                                                 /* Kopfzeile */
  1762.         {
  1763.             str=expandfkey(wp,form_read(tree2,PRNKZSTR,alertstr),i+1+pageoffset);
  1764.             ret=strlen(str);
  1765.             if(tree2[PRNKZL].ob_state&SELECTED)                            /* links */
  1766.                 blanks=lr;
  1767.             if(tree2[PRNKZM].ob_state&SELECTED)                            /* mitte */
  1768.                 blanks=lr+(zl-ret)/2;
  1769.             if(tree2[PRNKZR].ob_state&SELECTED)                          /* rechts */
  1770.                 blanks=(lr+zl-ret);
  1771.             if(tree3[PRNALT].ob_state&SELECTED)
  1772.             {
  1773.                 if(!((i+1+pageoffset)%2))    /* bei geraden Seiten vertauschen */
  1774.                 {
  1775.                     if(tree2[PRNKZR].ob_state&SELECTED)                  /* rechts */
  1776.                         blanks=lr;
  1777.                     if(tree2[PRNKZL].ob_state&SELECTED)                    /* links */
  1778.                         blanks=(lr+zl-ret);
  1779.                 }
  1780.             }
  1781.             x=max(X_MIN,X_MIN+blanks*cw);
  1782.             if(i==0) /* erste seite */
  1783.             {
  1784.                 if(!(tree3[PRNKFBEG].ob_state&SELECTED))            /* Kopfzeile */
  1785.                 {
  1786.                     x=X_MIN;
  1787.                     y+=ch;
  1788.                 }
  1789.                 else
  1790.                 {
  1791.                     if(handle)
  1792.                         v_gtext(handle,x,y,str);
  1793.                     x=X_MIN;
  1794.                     y+=ch;
  1795.                 }
  1796.             }
  1797.             else
  1798.             {
  1799.                 if(handle)
  1800.                     v_gtext(handle,x,y,str);
  1801.                 x=X_MIN;
  1802.                 y+=ch;
  1803.             }
  1804.             x=X_MIN;
  1805.             y+=(kz-1)*ch;
  1806.         }
  1807.         for(k=0; k<zz && line; k++, line=line->next,count++)
  1808.         {
  1809.             if(*line->string!=FORMFEED)
  1810.             {
  1811.                 if(tree3[PRNCUT].ob_state&SELECTED)/* überlange Zeilen abschneiden */
  1812.                 {
  1813.                     if(zl<line->used)
  1814.                     {
  1815.                         c1=line->string[zl];
  1816.                         line->string[zl]=0;
  1817.                     }
  1818.                 }
  1819.                 x=max(X_MIN,lr*cw);
  1820.                 if(lcol<line->used)
  1821.                 {
  1822.                     c2=line->string[lcol];                             /* Druckspalte */
  1823.                     line->string[lcol]=0;
  1824.                 }
  1825.                 if(tree3[PRNNUM].ob_state & SELECTED)    /* Zeilennummerierung */
  1826.                 {
  1827.                     sprintf(alertstr,"%5ld: ",count);
  1828.                     if(handle)
  1829.                         v_gtext(handle,x,y,alertstr);
  1830.                     x+=strlen(alertstr)*cw;
  1831.                 }
  1832.                 if((fcol-1)<line->used)
  1833.                 {
  1834.                     if(handle)
  1835.                     {
  1836.                         if(line->effect != oldeffect) /* normal, fett, kursiv */
  1837.                         {
  1838.                             vst_effects(handle, line->effect);
  1839.                             oldeffect = line->effect;
  1840.                         }
  1841.                         v_gtext(handle,x,y,&line->string[fcol-1]);
  1842.                     }
  1843.                     x=X_MIN;
  1844.                     y+=ch;
  1845.                 }
  1846.                 else
  1847.                 {
  1848.                     x=X_MIN;
  1849.                     y+=ch;
  1850.                 }
  1851.                 if(lcol<line->used)
  1852.                     line->string[lcol]=c2;
  1853.                 if(tree3[PRNCUT].ob_state&SELECTED)
  1854.                 {
  1855.                     if(zl<line->used)
  1856.                     {
  1857.                         line->string[zl]=c1;
  1858.                     }
  1859.                 }
  1860.             }
  1861.             else
  1862.             {
  1863.                 line=line->next;
  1864.                 lines+=(zz-k);                              /* ...Zeilenzahl erhöhen */
  1865.                 pages=lines%zz ? (lines/zz)+1 : lines/zz;/* Anzahl der Seiten */
  1866.                 break;                      /* Seite beenden, aber FF nicht senden */
  1867.             }
  1868.         } /* for(k - zz) */
  1869.         if(i<(pages-1))
  1870.         {
  1871.             for(; k<zz; k++)                                  /* evtl. Leerzeilen */
  1872.                 x=X_MIN,y+=ch;
  1873.         }
  1874.         else /* wenn letzte Seite... */
  1875.         {
  1876.             if(fz || tree3[PRNFF].ob_state&SELECTED)/* nur bei FZ oder Knopf */
  1877.                 for(; k<zz; k++)                                  /* evtl. Leerzeilen */
  1878.                     x=X_MIN,y+=ch;
  1879.         }
  1880.         if(fz)                                                                  /* Fuβzeile */
  1881.         {
  1882.             str=expandfkey(wp,form_read(tree2,PRNFZSTR,alertstr),i+1+pageoffset);
  1883.             ret=strlen(str);
  1884.             x=X_MIN;
  1885.             y+=(fz-1)*ch;
  1886.             if(tree2[PRNFZL].ob_state&SELECTED)                            /* links */
  1887.                 blanks=lr;
  1888.             if(tree2[PRNFZM].ob_state&SELECTED)                            /* mitte */
  1889.                 blanks=lr+(zl-ret)/2;
  1890.             if(tree2[PRNFZR].ob_state&SELECTED)                          /* rechts */
  1891.                 blanks=(lr+zl-ret);
  1892.             if(tree3[PRNALT].ob_state&SELECTED)
  1893.             {
  1894.                 if(!((i+1+pageoffset)%2))              /* bei geraden Seiten vertauschen */
  1895.                 {
  1896.                     if(tree2[PRNFZR].ob_state&SELECTED)                  /* rechts */
  1897.                         blanks=lr;
  1898.                     if(tree2[PRNFZL].ob_state&SELECTED)                    /* links */
  1899.                         blanks=(lr+zl-ret);
  1900.                 }
  1901.             }
  1902.             x=max(X_MIN,X_MIN+blanks*cw);
  1903.             if(i==0) /* erste Zeile */
  1904.             {
  1905.                 if(!(tree3[PRNKFBEG].ob_state&SELECTED))            /* Fuβzeile? */
  1906.                 {
  1907.                     x=X_MIN;
  1908.                     y+=ch;
  1909.                 }
  1910.                 else
  1911.                 {
  1912.                     if(handle)
  1913.                         v_gtext(handle,x,y,str);
  1914.                     x=X_MIN;
  1915.                     y+=ch;
  1916.                 }
  1917.             }
  1918.             else
  1919.             {
  1920.                 if(handle)
  1921.                     v_gtext(handle,x,y,str);
  1922.                 x=X_MIN;
  1923.                 y+=ch;
  1924.             }
  1925.         }/* fz */
  1926.         if(handle && (i<(pages-1)))
  1927.         {
  1928.             v_updwk(handle);
  1929.             v_clrwk(handle);
  1930.         }
  1931.         if(tree3[PRNPAUSE].ob_state&SELECTED)
  1932.             if(form_alert(2,Aprinter[2])==1)
  1933.             {
  1934.                 result=FALSE;
  1935.                 goto ENDE;
  1936.             }
  1937.     }
  1938. ENDE:
  1939.     handle=save;
  1940.     form_exclose(tree1,-1,FALSE);
  1941.     tree1[PRTESC].ob_state&=~SELECTED;                                /* Bit löschen! */
  1942.     return(result);
  1943. }
  1944.  
  1945. int ismetafile(int channel)
  1946. {
  1947.     return((channel>=METAFILE) && (channel<CAMERA));
  1948. }
  1949.  
  1950. int gdosprint(OBJECT *tree1, OBJECT *tree2, OBJECT *tree3, WINDOW *wp, int device, char *filename)
  1951. {
  1952.     int i,handle=0,add,id,pt,ret,ch,result/*,pxy[5],eff[3]*/;
  1953. /*
  1954.     char name[34];
  1955. */
  1956.     if(wp)
  1957.     {
  1958.         if(vq_gdos())
  1959.         {
  1960.             graf_mouse(BUSY_BEE,NULL);
  1961.             if(!scrollist)
  1962.                 scan_assignsys(tree2,gdospop);
  1963.             if(!ismetafile(device)/*!=METAFILE*/)                    /* Also bei Druckern */
  1964.             {                                             /* Papiergröβe einstellen */
  1965.                 handle=open_work(device);      /* physikalisch öffnen */
  1966. #if GEMDOS
  1967.                 if((handle>0) && (act_paper!=POPBASIS))/* bei POPBASIS nicht ändern */
  1968.                 {
  1969.                     close_work(handle,device);                /* Workstation schlieβen */
  1970.                     _VDIParBlk.contrl[1] = 1;
  1971.                     _VDIParBlk.ptsin [0] = (int)((long)ps[act_paper-POPBASIS/*POPLETT*/].w*100/work_out[3]);
  1972.                     _VDIParBlk.ptsin [1] = (int)((long)ps[act_paper-POPBASIS/*POPLETT*/].h*100/work_out[4]);
  1973.                     for (i = 0; i < 103; i++) work_in [i] = 1;
  1974.                     work_in [0]  = device;                                    /* Devicehandle */
  1975.                     work_in [10] = 2;                                  /* Raster Koordinaten */
  1976.                     work_in [11] = 255;         /* OW_NOCHANGE parallel or serial port */
  1977.                     _V_opnwk (work_in, &handle, work_out);  /* physikalisch öffnen */
  1978.                 }
  1979. #endif
  1980.             }
  1981.             else
  1982.                 handle=open_work(device);      /* physikalisch öffnen */
  1983.             graf_mouse(ARROW,NULL);
  1984.  
  1985.             if(handle>0)
  1986.             {
  1987.                 if(ismetafile(device)/*==METAFILE*/)                             /* bei Metafiles... */
  1988.                 {
  1989.                     vm_filename(handle,filename); /* Dateiname und Koordianten */
  1990.  
  1991.                     v_meta_extents(handle,0,0,ps[act_paper-POPBASIS/*POPLETT*/].w-1,
  1992.                                                       ps[act_paper-POPBASIS/*POPLETT*/].h-1);
  1993.                     vm_pagesize(handle,ps[act_paper-POPBASIS/*POPLETT*/].w,
  1994.                                              ps[act_paper-POPBASIS/*POPLETT*/].h);
  1995.                     vm_coords(handle,0,ps[act_paper-POPBASIS/*POPLETT*/].h-1,
  1996.                                              ps[act_paper-POPBASIS/*POPLETT*/].w-1,0);
  1997.                 }
  1998.             if(vq_vgdos()==0x5F46534D)
  1999.                 vst_scratch(handle,2); /* FSM Scratchbuffer auf null, sonst geht nicht */
  2000.                 add=vst_load_fonts(handle,0);                /* Fonts laden */
  2001.                 id=vst_font(handle,wp->fontid);            /* Font wählen */
  2002.                 pt=vst_point(handle,wp->fontsize,&ret,&ret,&ret,&ch); /* pts */
  2003. /*
  2004.                 vqt_fontinfo(handle, &ret, &ret, pxy, &ret, eff);
  2005.                 ch = pxy[0] + pxy[4] + 1;
  2006. */
  2007.                 if(id!=wp->fontid || pt!=wp->fontsize) /* irdendwas paβte nicht */
  2008.                 {
  2009.                     if(ismetafile(device)/*==METAFILE*/)/* bei Metafiles... */
  2010.                         form_alert(1,Aprinter[14]);        /* Warnung ausgeben */
  2011.                     else
  2012.                         form_alert(1,Aprinter[15]);        /* Warnung ausgeben */
  2013.                     vst_unload_fonts(handle,0);            /* Fonts freigeben */
  2014.                     close_work(handle,device);                /* Workstation schlieβen */
  2015.                     if(ismetafile(device)/*==METAFILE*/)/* bei Metafiles... */
  2016.                     {
  2017.                         unlink(filename);
  2018.                         cut_path(filename);
  2019. /*
  2020.                         strcut(filename,'\\');
  2021. */
  2022.                         strcat(filename,"GEMFILE.GEM"); /* GEMFILE.GEM löschen */
  2023.                         unlink(filename);
  2024.                         unlink("GEMFILE.GEM");
  2025.                         strcpy(filename,"GEMFILE.GEM"); /* GEMFILE.GEM löschen */
  2026. /* 23.10.94
  2027.                         shel_find(filename);
  2028. */
  2029.                         if(*filename)
  2030.                             unlink(filename);
  2031.                     }
  2032. /*
  2033.                     graf_mouse(ARROW,NULL);
  2034. */
  2035.                     return;                                    /* ...und abbrechen */
  2036.                 }
  2037.  
  2038.                 if(ismetafile(device)/*==METAFILE*/)/* Maximale Zeilenzahl korrigieren */
  2039.                 {
  2040.                     if(act_dist==POPD1)
  2041.                         bl=min(bl,(ps[act_paper-POPBASIS/*POPLETT*/].h/ch-UNPRINTABLE_LINES));
  2042.                     if(act_dist==POPD1+1)
  2043.                         bl=min(bl,(ps[act_paper-POPBASIS/*POPLETT*/].h/ch-UNPRINTABLE_LINES)*2/3);
  2044.                     if(act_dist==POPD1+2)
  2045.                         bl=min(bl,(ps[act_paper-POPBASIS/*POPLETT*/].h/ch-UNPRINTABLE_LINES)/2);
  2046.                     zz=bl-or-kz-fz-ur;
  2047.                 }
  2048.                 else
  2049.                 {
  2050.                     zz=bl-or-kz-fz-ur;
  2051.                 }
  2052.  
  2053.                 result=v_gdosprt(tree1,tree2,tree3,wp,handle); /* eigentliche Ausgabe */
  2054. WEITER:
  2055.                 if(!ismetafile(device)/*!=METAFILE*/)  /* Seitenvorschub beim Drucken hinterher */
  2056.                 {
  2057.                     v_updwk(handle);
  2058.                     v_clrwk(handle);
  2059.                 }
  2060.                 vst_unload_fonts(handle,0);                      /* Fonts freigeben */
  2061.                 close_work(handle,device);                  /* Workstation schlieβen */
  2062.                 if(ismetafile(device)/*==METAFILE*/)
  2063.                 {
  2064.                     cut_path(filename);
  2065. /*
  2066.                     strcut(filename,'\\');
  2067. */
  2068.                     strcat(filename,"GEMFILE.GEM");        /* GEMFILE.GEM löschen */
  2069.                     unlink(filename);
  2070.                     unlink("GEMFILE.GEM");
  2071.                     strcpy(filename,"GEMFILE.GEM"); /* GEMFILE.GEM löschen */
  2072. /* 23.10.94
  2073.                     shel_find(filename);
  2074. */
  2075.                     if(*filename)
  2076.                         unlink(filename);
  2077.                 }
  2078.             }
  2079.             else
  2080.             {
  2081.                 sprintf(alertstr,Aprinter[16],device);
  2082.                 form_alert(1,alertstr);
  2083.             }
  2084. /*
  2085.             graf_mouse(ARROW,NULL);
  2086. */
  2087.             return(result);
  2088.         }
  2089.         else
  2090.             form_alert(1,Aprinter[17]);
  2091.     }
  2092.     return(FALSE);
  2093. }
  2094.